using System;

using LocalBoard.Domain;
using LocalBoard.Persistence;

using NUnit.Framework;

namespace LocalBoard.Controller.Test
{
	/// <summary>
	/// Summary description for TestClubBoardController.
	/// </summary>
	[TestFixture]
	public class TestClubBoardController
	{
		private ClubBoardController _unitUnderTest = null;

		[SetUp]
		public void SetUp()
		{
			IAccessorFactory accessorFactory = new MockAccessorFactory();
			AdminController adminController = new AdminController(accessorFactory);
			int testUser1Id = adminController.CreateUser(new Profile("testUser11", "testUser1", "testUser1", "testUser1@test.com"));
			int testUser2Id = adminController.CreateUser(new Profile("testUser22", "testUser2", "testUser2", "testUser2@test.com"));
			int clubId = adminController.CreateClub(new Club("testClub1", "testClub1", 1, "testClub1", ClubType.Public, null));
			ClubController clubController = new ClubController(clubId, accessorFactory);
			clubController.AssignClubManager(testUser1Id);
			int board1Id = clubController.CreateBoard(new Board("testClub1Board1", null, 0, 0, clubId, BoardViewType.List));
			BoardController boardController1 = new BoardController(board1Id, clubController, 0, accessorFactory);
			boardController1.PostMessage("testMsg", "testMsg", adminController.GetUser(testUser1Id), 0); 
			int board2Id = clubController.CreateBoard(new Board("testClub1Board2", null, 0, 0, clubId, BoardViewType.List));
			BoardController boardController2 = new BoardController(board2Id, clubController, 0, accessorFactory);
			boardController2.PostMessage("testMsg", "testMsg", adminController.GetUser(testUser2Id), 0); 
			
			_unitUnderTest = new ClubBoardController(clubController, 0, accessorFactory);
		}
		[TearDown]
		public void TearDown()
		{
			_unitUnderTest = null;
			MockAccessorFactory.ResetDataTable();
		}

		[Test]
		public void TestTotalPageNumber()
		{
			Assert.AreEqual(1, _unitUnderTest.TotalPageNumber) ;
		}

		[Test]
		public void TestTotalRootMessageCount()
		{
			Assert.AreEqual(2, _unitUnderTest.TotalRootMessageCount) ;
		}

		[Test]
		public void TestGetMessageListForCurrentPage()
		{
			Assert.AreEqual(2, _unitUnderTest.GetMessageListForCurrentPage().Count) ;
		}
	}
}
